<template>
  <!-- 收货启动,记录卸货人 -->
		<div class="ywshouhuo_xhr">

			<van-nav-bar :fixed="true" class="navBar" title="托盘混载" left-arrow @click-left="$router.go(-1)"></van-nav-bar> <!-- 导航栏 -->

				<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
					同一托盘的多张入库标签绑定
				</van-notice-bar>

				<div class="goodsFromWarp">

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>
								<van-field
									 clearable
									 class="skuInput"
									 v-model="editForm.jhrq"
									 placeholder="请填写入库标签"
								 />
								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn1()" >
										<van-icon name="search" size="20" color="#1989fa"  />
									</button>
								</div>
						</div>

						<div class="tishiMessage">
							{{skuRow1}}
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>
								<van-field
									 clearable
									 class="skuInput"
									 v-model="editForm.jhrq1"
									 placeholder="请填写入库标签"
								 />
								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn2()" >
										<van-icon name="search" size="20"  color="#1989fa"  />
									</button>
								</div>
						</div>
						<div class="tishiMessage">
							{{skuRow2}}
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>
								<van-field
									 clearable
									 class="skuInput"
									 v-model="editForm.jhrq2"
									 placeholder="请填写入库标签"
								 />
								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn3()" >
										<van-icon name="search"  size="20"  color="#1989fa"  />
									</button>
								</div>
						</div>
						<div class="tishiMessage">
							{{skuRow3}}
						</div>


						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">入库标签：</div>
								</div>
								<van-field
									 clearable
									 class="skuInput"
									 v-model="editForm.jhrq3"
									 placeholder="请填写入库标签"
								 />
								<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="searchGoodsBtn4()" >
										<van-icon name="search" size="20"   color="#1989fa"  />
									</button>
								</div>
						</div>
						<div class="tishiMessage">
							{{skuRow4}}
						</div>

				</div>


				<van-dialog v-model="carMessageIsShow" title="请确认下列入库标签商品在同一托盘：" show-cancel-button @confirm = "_getSaveHunZaiClick()" confirmButtonColor="#1989fa">
					<div style="width: 100%;display: flex;flex-direction: column;align-items: center;margin-top: 8px;">
						<div>
							<p class="messageConTitle">{{editForm.jhrq}}</p>
							<p class="messageConTitle">{{editForm.jhrq1}}</p>
							<p class="messageConTitle">{{editForm.jhrq2}}</p>
							<p class="messageConTitle">{{editForm.jhrq3}}</p>
						</div>
					</div>
				</van-dialog>


				<div class="skuBtn" style="justify-content: flex-end;">
					<van-button type="info" :disabled="isdisabled" @click="baocunClick()">保存</van-button>
				</div>
		</div>

</template>

<script>
import { mapActions } from "vuex";
export default {
  name: 'tuopanhunzai',
  data () {
    return {
			editForm:{
				jhrq:'',  //入库标签
				jhrq1:'', //入库标签
				jhrq2:'', //入库标签
				jhrq3:'', //入库标签
				jhrq4:'', //入库标签
			},
			skuRow1:'',
			skuRow2:'',
			skuRow3:'',
			skuRow4:'',
			isdisabled:false, //是否禁用
			tableData:[], //表格数据
			carMessageIsShow:false //是否显示弹窗
    }
  },
  methods: {
		 ...mapActions(["showLoading", "hideLoading"]), //显示和隐藏loading
		 searchGoodsBtn1(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_shouhuo',
				'i':this.FNULLE([
					'opmode','Y_TPHZ_qryshserno',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'jhrq',this.editForm.jhrq,
				])
				}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到入库标签查询")
					console.log(rtn_json_obj[0])
					if(rtn_json_obj[0].ret_ret == '0'){
						_self.skuRow1 = rtn_json_obj[0].ret_mess1
					}else{
						_self.$toast.fail('暂无预检单')
					}
				}
			 });
		 },
		 searchGoodsBtn2(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_qryshserno',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq',this.editForm.jhrq1,
					])
					}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到入库标签查询")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.skuRow2 = rtn_json_obj[0].ret_mess1
						}else{
							_self.$toast.fail('暂无预检单')
						}
					}
			 });
		 },
		 searchGoodsBtn3(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_qryshserno',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq',this.editForm.jhrq2,
					])
					}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到入库标签查询")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.skuRow3 = rtn_json_obj[0].ret_mess1
						}else{
							_self.$toast.fail('暂无预检单')
						}
					}
			 });
		 },
		 searchGoodsBtn4(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_qryshserno',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq',this.editForm.jhrq3,
					])
					}, '入库标签查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到入库标签查询")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.skuRow4 = rtn_json_obj[0].ret_mess1
						}else{
							_self.$toast.fail('暂无预检单')
						}
					}
			 });
		 },
		 baocunClick(){
			 if(this.editForm.jhrq > '' && (this.editForm.jhrq1>'' || this.editForm.jhrq2>'' || this.editForm.jhrq3>'')){
				 this.carMessageIsShow = true
			 }else{
				 this.$toast.fail('最少得有俩个托盘')
			 }

		 },
		 _getSaveHunZaiClick(){
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_shouhuo',
					'i':this.FNULLE([
						'opmode','Y_TPHZ_tphzbd',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'jhrq1',this.editForm.jhrq,
						'jhrq2',this.editForm.jhrq1,
						'jhrq3',this.editForm.jhrq2,
						'jhrq4',this.editForm.jhrq3,
					])
					}, '托盘混载提交',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到托盘混载提交")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '0'){
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
							_self.editForm.jhrq = ''
							_self.editForm.jhrq1 = ''
							_self.editForm.jhrq2 = ''
							_self.editForm.jhrq3 = ''
							_self.skuRow1 = ''
							_self.skuRow2 = ''
							_self.skuRow3 = ''
							_self.skuRow4 = ''
						}else{
							_self.$toast.fail(rtn_json_obj[0].ret_mess)
						}
					}
			 });
		 }
  },
  components:{

  },
  computed: {
     ryuser: function(){
       return this.GWO(true).gUSER;
     }
  },
  mounted :function(){
    var _self = this; window.GWO().debug=this;
  }
}

</script>
<style scoped lang="scss">
// 引入公共样式
@import '@/assets/css/base.scss';
@import '@/assets/css/input.scss';
.ywshouhuo_xhr{
	padding-top:50px;
	padding-bottom: 50px;
}
.xiehuoren{
	width:100px;
	font-size: 12px;
	margin-left: 10px;
}

.tishiMessage{
	width: 100%;
	height: 30px;
	font-size: 20px;
	font-weight: bold;
}

.messageConTitle{
	margin-top: 10px;
	margin-bottom: 10px;
}

</style>

